package cn.kgc.springmvc.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttribute;
import org.springframework.web.bind.annotation.SessionAttributes;

/**
 * @author: mosin
 * @version: v1.0  2022/5/5
 */
@Controller
@RequestMapping("/session")
@SessionAttributes("msg")
public class SessionController {

    @RequestMapping("/s1")
    public String test01(Model model){
        model.addAttribute("msg", "session value");
        System.out.println("请求被接收");
        return "redirect:/static/session.jsp";
    }

    //使用注解实现session域中的取值
    @RequestMapping("/s2")
    public String test02(@SessionAttribute("msg") String msg){
        System.out.println("msg = " + msg);
        return "redirect:/static/session.jsp";
    }



}
